找传奇、传世资源到传世资源站!

listview设置不同图标

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

from clipboard
from clipboardusing System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;using OAKControls;namespace CSListView{/// <summary>/// Summary description for Form1./// </summary>public class Form1 : System.Windows.Forms.Form{private OAKListView listView1;private System.Windows.Forms.ColumnHeader columnHeader1;private System.Windows.Forms.ColumnHeader columnHeader2;private System.Windows.Forms.ColumnHeader columnHeader3;private System.Windows.Forms.ColumnHeader columnHeader4;private System.Windows.Forms.ColumnHeader columnHeader5;private System.Windows.Forms.ImageList imageList1;private System.Windows.Forms.Button button1;private System.ComponentModel.IContainer components;public Form1(){//// Required for Windows Form Designer support//InitializeComponent();//// TODO: Add any constructor code after InitializeComponent call//}/// <summary>/// Clean up any resources being used./// </summary>protected override void Dispose( bool disposing ){if( disposing ){if (components != null) {components.Dispose();}}base.Dispose( disposing );}#region Windows Form Designer generated code/// <summary>/// Required method for Designer support - do not modify/// the contents of this method with the code editor./// </summary>private void InitializeComponent(){this.components = new System.ComponentModel.Container();System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));this.listView1 = new OAKControls.OAKListView();this.columnHeader1 = new System.Windows.Forms.ColumnHeader();this.columnHeader2 = new System.Windows.Forms.ColumnHeader();this.columnHeader3 = new System.Windows.Forms.ColumnHeader();this.columnHeader4 = new System.Windows.Forms.ColumnHeader();this.columnHeader5 = new System.Windows.Forms.ColumnHeader();this.imageList1 = new System.Windows.Forms.ImageList(this.components);this.button1 = new System.Windows.Forms.Button();this.SuspendLayout();// // listView1// this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {this.columnHeader1,this.columnHeader2,this.columnHeader3,this.columnHeader4,this.columnHeader5});this.listView1.GridLines = true;this.listView1.Location = new System.Drawing.Point(8, 8);this.listView1.Name = "listView1";this.listView1.Size = new System.Drawing.Size(496, 336);this.listView1.TabIndex = 0;this.listView1.View = System.Windows.Forms.View.Details;// // columnHeader1// this.columnHeader1.Width = 100;// // columnHeader2// this.columnHeader2.Width = 100;// // columnHeader3// this.columnHeader3.Width = 100;// // columnHeader4// this.columnHeader4.Width = 100;// // columnHeader5// this.columnHeader5.Width = 92;// // imageList1// this.imageList1.ImageSize = new System.Drawing.Size(16, 16);this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));this.imageList1.TransparentColor = System.Drawing.Color.Transparent;// // button1// this.button1.Location = new System.Drawing.Point(8, 352);this.button1.Name = "button1";this.button1.Size = new System.Drawing.Size(172, 23);this.button1.TabIndex = 1;this.button1.Text = "Click to add image on SubItems";this.button1.Click = new System.EventHandler(this.button1_Click);// // Form1// this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);this.ClientSize = new System.Drawing.Size(512, 387);this.Controls.Add(this.button1);this.Controls.Add(this.listView1);this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;this.MaximizeBox = false;this.Name = "Form1";this.Text = "OAK ListView";this.Load = new System.EventHandler(this.Form1_Load);this.ResumeLayout(false);}#endregion/// <summary>/// The main entry point for the application./// </summary>[STAThread]static void Main() {Application.Run(new Form1());}private void Form1_Load(object sender, System.EventArgs e){listView1.SmallImageList = imageList1;listView1.FullRowSelect = true;listView1.GridLines = true;listView1.View = View.Details;for(int I=0;I<=15;I ){ListViewItem lvi = new ListViewItem(new string[]{"aaaaa","bbbb","cccc","dddd","eeee","ffff","gggg","hhhh"});lvi.ImageIndex = 1;listView1.Items.Add(lvi);}}private void button1_Click(object sender, System.EventArgs e){for(int x=0;x<=listView1.Items.Count;x ){for(int I=0;I<listView1.Columns.Count;I ){OAKListView.LV_ITEM lvi = new OAKListView.LV_ITEM();// Rowlvi.iItem = x; // Columnlvi.iSubItem = I;lvi.pszText = "OAKListView-" I.ToString();lvi.mask = OAKListView.LVIF_IMAGE | OAKListView.LVIF_TEXT; // Image index on imagelistlvi.iImage = I;OAKListView.SendMessage(listView1.Handle, OAKListView.LVM_SETITEM, 0, ref lvi);}}MessageBox.Show("Tchanannnnn....", "OAKListView", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);}}}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复